// pages/mine/MyVehicle/UploadCertifly/UploadCertifly.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    idInfo:'',
    imgZH:'',
    imgFA:'',
    idZH:'',
    idFA:'',
    judge:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      console.log(options.id)
      this.setData({
        idInfo:options.id
      })
     
  },
  chooseImage(){
    var _this=this
    wx.chooseImage({
      count: 1, // 最多可以选择的图片张数，默认9
      sizeType: ['original', 'compressed'], // original 原图，compressed 压缩图，默认二者都有
      sourceType: ['camera','album'], // album 从相册选图，camera 使用相机，默认二者都有
      success: function(res){
         if(_this.data.idInfo==1&&_this.data.judge=='zh'){
              _this.setData({
                imgZH:res.tempFilePaths[0]
              })
          }else if(_this.data.idInfo==1&&_this.data.judge=='fa'){
            _this.setData({
              imgFA:res.tempFilePaths[0]
            })
          }else if(_this.data.idInfo==2&&_this.data.judge=='zh'){
            _this.setData({
              idZH:res.tempFilePaths[0]
            })
          }else if(_this.data.idInfo==2&&_this.data.judge=='fa'){
            _this.setData({
              idFA:res.tempFilePaths[0]
            })
          }
     
      },
      fail: function() {
      // fail
      },
      complete: function() {
      // complete
      } 
    })
  },
  gotoShowZH(e){
    this.setData({
      judge:e.currentTarget.dataset.id
    })
    this.chooseImage()
  },
  getShowZH(e){
    this.setData({
      judge:e.currentTarget.dataset.id
    })
    this.chooseImage()
    
  },
  gotoShowFA(e){
    this.setData({
      judge:e.currentTarget.dataset.id
    })
    this.chooseImage()
  },
  getShowFA(e){
    this.setData({
      judge:e.currentTarget.dataset.id
    })
    this.chooseImage()
  },
  newVehicle(){
    if(this.data.idInfo==1){
      console.log(this.data.imgZH)
      console.log(this.data.imgFA)
    }else if(this.data.idInfo==2){
      console.log(this.data.idZH)
      console.log(this.data.idFA)
    }
  }
})